{% extends "admin_base.html" %}

{% block title %}Post List - Admin - Blog{% endblock %}

{% block page_content %}
<div class="pure-g">
  <div class="pure-u">
    <table class="pure-table pure-table-bordered">
        <thead>
            <tr>
                <td>#</td>
                <td>Nick Name</td>
                <td>Email</td>
                <td>Active</td>
                <td>Role</td>
                <td>Action</td>
            </tr>
        </thead>
        <tbody>
           {% for u in user_list %}
            <tr>
                <td>{{ loop.index }}</td>
                <td><a href="#">{{ u.nick_name }}</a></td>
                <td>{{ u.email }}</td>
                <td>{{ u.active }}</td>
                <td>{{ u.role }}</td>
                <td>
                    <a href="{{ uri_for('admin-user') }}?uid={{ u.key().id() }}">Edit</a>
                    <a href="{{ uri_for('admin-user') }}?action=delete&uid={{ u.key().id() }}">Delete</a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
  </div>
</div>
<div class="pure-g">
  <div class="pure-u">
    <form action="{{ uri_for('admin-user') }}" method="POST" class="pure-form-stacked">
        <fieldset>
            <legend>New user</legend>
            <input type="hidden" id="inp_uid" name="uid" value="{% if account %}{{ account.key().id() }}{% endif %}"/>
            <label for="inp_nickname">Nick Name: </label>
            <input type="text" id="inp_nickname" name="nickname" value="{{ account.nick_name }}" placeholer="Nick Name" />
            <label for="inp_email">Email: </label>
            <input type="text" id="inp_email" name="email" value="{{ account.email }}" placeholer="Email" />
            <label for="inp_role">Role: </label>
            {# <input type="text" id="inp_role" name="role" value="{{ account.role }}" placeholer="Role" /> #}
            <select id="inp_role" name="role">
                {% for r in ['admin', 'editor', 'author']%}
                <option value="{{ r }}"{% if account.role == r %} selected{% endif %}>{{ r }}</option>
                {% endfor %}
            </select>
            <label for="chk_active">
                <input type="checkbox" id="chk_active" name="active" {% if account.active %}checked="yes"{% endif %}>Active
            </label>
            <button type="submit" class="pure-button notice">Save</button>
        </fieldset>
    </form>
  </div>
</div>
{% endblock %}
